﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="Material.aspx.cs" Inherits="UdrinkWater_Project.Admin.Material" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataMaterial" KeyFieldName="Material_ID" Width="100%">
        <Columns>
            <dx:GridViewCommandColumn VisibleIndex="3">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
                <DeleteButton Visible="True">
                </DeleteButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="Material_ID" VisibleIndex="0">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Materail_name" VisibleIndex="1">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn FieldName="Unit" VisibleIndex="2">
                <PropertiesComboBox DataSourceID="SqlDataUnit_Category" TextField="Unit_Name" 
                    ValueField="Unit_ID" ValueType="System.Int32">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
        </Columns>
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataMaterial" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        DeleteCommand="DELETE FROM [TB_Material] WHERE [Material_ID] = @original_Material_ID AND (([Materail_name] = @original_Materail_name) OR ([Materail_name] IS NULL AND @original_Materail_name IS NULL)) AND (([Unit] = @original_Unit) OR ([Unit] IS NULL AND @original_Unit IS NULL))" 
        InsertCommand="INSERT INTO [TB_Material] ([Material_ID], [Materail_name], [Unit]) VALUES (@Material_ID, @Materail_name, @Unit)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT [Material_ID], [Materail_name], [Unit] FROM [TB_Material]" 
        UpdateCommand="UPDATE [TB_Material] SET [Materail_name] = @Materail_name, [Unit] = @Unit WHERE [Material_ID] = @original_Material_ID AND (([Materail_name] = @original_Materail_name) OR ([Materail_name] IS NULL AND @original_Materail_name IS NULL)) AND (([Unit] = @original_Unit) OR ([Unit] IS NULL AND @original_Unit IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_Material_ID" Type="String" />
            <asp:Parameter Name="original_Materail_name" Type="String" />
            <asp:Parameter Name="original_Unit" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Material_ID" Type="String" />
            <asp:Parameter Name="Materail_name" Type="String" />
            <asp:Parameter Name="Unit" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Materail_name" Type="String" />
            <asp:Parameter Name="Unit" Type="Int32" />
            <asp:Parameter Name="original_Material_ID" Type="String" />
            <asp:Parameter Name="original_Materail_name" Type="String" />
            <asp:Parameter Name="original_Unit" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataUnit_Category" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT [Unit_ID], [Unit_Name] FROM [TB_Unit_Category]">
    </asp:SqlDataSource>
</asp:Content>
